package com.guxing.authConfig;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.util.function.Function;

@Data
@Configuration
@ConfigurationProperties(prefix = "auth")
@RefreshScope
public class AuthConfig {
    public AuthConfig() {
        this.adminIdentity = 999;
    }

    /**
     * dataSource
     */
    private DataSource dataSource;

    /**
     * AppName
     */
    private String appName;

    /**
     * 组件在生日日期对象时所使用的时区
     */
    private String timeZone;

    /**
     * 帐户类型，不同帐户类型下的帐号互相独立，取值由应用系统自己定义，比如货主端，司机端等
     */
    private int ownerType;

    /**
     * 帐户类型
     */
    private int adminIdentity;


    /**
     * 用户策略
     */
    private AccountPolicy accountPolicy;

    /**
     * 密码策略
     */
    private PasswordPolicy passwordPolicy;

    /**
     * 登录策略
     */
    private LoginPolicy loginPolicy;

    /**
     * 会话策略
     */
    private SessionPolicy sessionPolicy;


    /**
     * 是否开启ip转物理地址，true=开启，false=关闭
     */
    private boolean ipToAddressEnabled;

    /**
     * ip转物流地址函数
     */
    private Function<String, String> ipToAddressFunc;

    @Override
    public String toString() {
        return "AuthConfig{" +
                "dataSource=" + dataSource +
                ", appName='" + appName + '\'' +
                ", timeZone='" + timeZone + '\'' +
                ", ownerType=" + ownerType +
                ", adminIdentity=" + adminIdentity +
                ", accountPolicy=" + accountPolicy +
                ", passwordPolicy=" + passwordPolicy +
                ", loginPolicy=" + loginPolicy +
                ", sessionPolicy=" + sessionPolicy +
                ", ipToAddressEnabled=" + ipToAddressEnabled +
                ", ipToAddressFunc=" + ipToAddressFunc +
                '}';
    }
}
